package com.hjxr.sysadmin.zsj.controller;

import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.Pagephoto;
import com.hjxr.sysadmin.zsj.domain.Policys;
import com.hjxr.sysadmin.zsj.service.IPagephotoService;
import com.hjxr.sysadmin.zsj.service.IPolicysService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 政策信息Controller
 *
 * @date 2021-03-08
 */
@Api("政策用户信息管理")
@RestController
@RequestMapping("/policys")
public class PolicysController extends BaseController {
	@Autowired
	private IPolicysService policysService;

	/**
	 * 查询政策信息列表
	 */
	@ApiOperation("查询政策信息列表")
	@GetMapping("/list")
	public TableDataInfo list(Policys policys) {
		startPage();
		List<Policys> list = policysService.selectPolicysList(policys);
		return getDataTable(list);
	}

	/**
	 * 导出政策信息列表
	 */
	@ApiOperation("导出政策信息列表")
	@Log(title = "政策信息", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(Policys policys) {
		List<Policys> list = policysService.selectPolicysList(policys);
		ExcelUtil<Policys> util = new ExcelUtil<Policys>(Policys.class);
		return util.exportExcel(list, "policys");
	}

	/**
	 * 获取政策信息详细信息
	 */
	@ApiOperation("获取政策信息详细信息")
	@GetMapping(value = "/{policyId}")
	public AjaxResult getInfo(@PathVariable("policyId") Long policyId) {
		return AjaxResult.success(policysService.selectPolicysById(policyId));
	}

	/**
	 * 新增政策信息
	 */
	@ApiOperation("新增政策信息")
	@Log(title = "政策信息", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody Policys policys) {
		return toAjax(policysService.insertPolicys(policys));
	}

	/**
	 * 修改政策信息
	 */
	@ApiOperation("修改政策信息")
	@Log(title = "政策信息", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody Policys policys) {
		return toAjax(policysService.updatePolicys(policys));
	}

	/**
	 * 删除政策信息
	 */
	@ApiOperation("删除政策信息")
	@Log(title = "政策信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{policyIds}")
	public AjaxResult remove(@PathVariable Long[] policyIds) {
		return toAjax(policysService.deletePolicysByIds(policyIds));
	}
}

